home *** CD-ROM | disk | FTP | other *** search
- /* -----------------------------------------------------------------------------
-
- Scan handler looking for include lines.
-
- Scan handlers are plain functions (loadSeg()'ed): no standard C startup
- code and no library calls permitted. We have to put string constants into
- the code segment (DICE compiler: option -ms1).
-
- DICE:
-
- dcc include.c -// -l0 -md -mRR -o golded:etc/scanner/include
-
- ------------------------------------------------------------------------------
- */
-
- #include <exec/types.h>
-
- ULONG
- ScanHandlerInclude(__D0 ULONG len, __A0 char **text, __A1 ULONG *line)
- {
- const char *version = "$VER: Include 1.5 (" __COMMODORE_DATE__ ")";
-
- STRPTR textPtr = *text;
-
- // ignore leading spaces
-
- while (len && ((*textPtr == ' ') || (*textPtr == 9))) {
-
- ++textPtr;
- --len;
- }
-
- // is the next word #include ?
-
- if (len > 8) {
-
- if ((textPtr[0] == '#') && (textPtr[1] == 'i') && (textPtr[2] == 'n') && (textPtr[3] == 'c') && (textPtr[4] == 'l') && (textPtr[5] == 'u') && (textPtr[6] == 'd') && (textPtr[7] == 'e')) {
-
- textPtr += 8;
- len -= 8;
-
- // ignore spaces before argument
-
- while (len && ((*textPtr == ' ') || (*textPtr == 9))) {
-
- ++textPtr;
-
- --len;
- }
-
- if (len) {
-
- UWORD marker;
-
- // determine argument delimiter
-
- switch (*textPtr) {
-
- case 34:
-
- marker = 34;
-
- ++textPtr;
- --len;
-
- break;
-
- case '<':
-
- marker = '>';
-
- ++textPtr;
- --len;
-
- break;
-
- default:
-
- marker = FALSE;
- }
-
- if (len && marker) {
-
- UWORD letters = 0;
-
- // result begins here (e.g. "file name" or <file name>)
-
- *text = textPtr;
-
- // determine agument length
-
- while (--len) {
-
- ++letters;
- ++textPtr;
-
- if (*textPtr == marker)
-
- return(letters);
- }
- }
- }
- }
- }
-
- return(0);
- }
-